package Service;

import Dao.Impl.PetDaoImpl;
import Entity.pet;

import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

public class PetServiceImpl implements PetService {
    PetDaoImpl petDao = new PetDaoImpl();
    @Override
    public void findAllPet() throws SQLException {
        System.out.println("****************************************");
        List<pet> pets = new ArrayList<pet>();
        pets=petDao.AllGetPet();
        for (pet p:pets)
        {
            System.out.println("第"+p.getId()+"个宠物，名字叫："+p.getName());
        }

    }
    public void add(pet p) throws SQLException, ParseException {
        try{
            petDao.add(p);
            System.out.println("添加成功");
        }
        catch (Exception e)
        {
            System.out.println("添加失败");
        }

    }
}
